<template>
  <view v-if="!loading && supplierStatus != 2">
    <register v-if="supplierStatus == 0"></register>
    <application v-else @reset-form="resetForm"></application>
  </view>
</template>

<script>
import register from "./register.vue";
import application from "./application_status.vue";
export default {
  components: {
    register,
    application,
  },
  data() {
    return {
      supplierStatus: -1,
      loading: true,
    };
  },
  onLoad() {
    console.log("llll");
    this.getData();
  },
  methods: {
    getData() {
      let self = this;
      uni.showLoading({
        title: "加载中...",
      });
      self.loading = true;
      self._postBody("user/index/index", {}, (res) => {
        self.supplierStatus = res.data.supplierStatus;

        if (self.supplierStatus == 2) {
          self.gotoPage("pages/user/my_shop/my_shop", "redirect");
        } else if (self.supplierStatus == 3) {
          uni.hideLoading();
          uni.showModal({
            content: "商户异常,请联系客服处理",
          });
          uni.navigateBack({});
        } else {
          let title = "";
          if (self.supplierStatus == 0) {
            title = "申请入驻";
          } else {
            title = "申请审核中";
          }
          uni.setNavigationBarTitle({
            title: title,
          });

          self.loading = false;
          uni.hideLoading();
        }
      });
    },
    resetForm() {
      this.form = true;
      console.log("llll");
    },
  },
};
</script>

<style></style>
